package com.iori.common.db.dbctrl;

import java.util.List;

/**
 * [クラス名]<br>
 * SQLファイルローダー<br>
 * <br>
 * [機能概要]<br>
 * sql broken <br>
 * <br>
 * [変更履歴]<br>
 * 2007/11/12 ver1.00 新規作成 Liuww<br>
 * <br>
 *
 * @author Liuww
 * @version 1.00
 */
public class SqlBrokenModel {

	//sql segment
	private  List sqlSegmentList = null;

	//sql type
	private int type = -1;

	//original sql
	private String originalSql = null;

	public String toString(){
		StringBuffer sb = new StringBuffer("");
		for(int i = 0 ; i < sqlSegmentList.size() ; i++){
			SqlElementModel sqlObj = (SqlElementModel)sqlSegmentList.get(i);
			if(sqlObj.getType() == SqlElementModel.TYPE_IGETA){
				//「{}」
				sb.append("{:"+sqlObj.getConditionName());
				List sqlElements = sqlObj.getSqlElements();
				for(int j = 0 ; j < sqlElements.size(); j++){
					SqlElementModel sqlElementsModel = (SqlElementModel)sqlElements.get(j);
					if(sqlElementsModel.getType() == SqlElementModel.TYPE_NAKAKAKKO){
						sb.append("#" + sqlElementsModel.getConditionName());
					}else{
						sb.append(sqlElementsModel.getSqlContent());
					}
				}
				sb.append("}");
			}else if(sqlObj.getType() == SqlElementModel.TYPE_NAKAKAKKO){
				//「#」
				sb.append("#" + sqlObj.getConditionName());
			}else{
				sb.append(sqlObj.getSqlContent());
			}
		}
		return sb.toString();
	}

	protected List getSqlSegmentList() {
		return sqlSegmentList;
	}

	protected void setSqlSegmentList(List sqlSegmentList) {
		this.sqlSegmentList = sqlSegmentList;
	}

	protected int getType() {
		return type;
	}

	protected void setType(int type) {
		this.type = type;
	}

	public String getOriginalSql() {
		return originalSql;
	}

	protected void setOriginalSql(String originalSql) {
		this.originalSql = originalSql;
	}
}
